// JavaScript Document
var Shoes = YAHOO;
var $D = Shoes.util.Dom;
var $E = Shoes.util.Event;
var $ = $D.get;

/*
	说明：根据ID或CLASSNAME获取对象
	参数element类型: string
	返回: object || array
*/
var $ = function(element){
	//对象不处理
	if(!Shoes.lang.isString(element)){
		return element;
	}
	//返回的对象数组
	var els = new Array();
	
	if(element.indexOf(",")>0){
		els = element.split(",");
	}else if(element.indexOf(" ")>0){
		els = element.split(" ");
	}else{
		els[0] = element;
	}
	
	for(var i=0, n=els.length; i<n; i++){
		if(els[i].charAt(0)=="#"){
			els[i] = $D.get(els[i].substring(1,els[i].length));
		}else if(els[i].charAt(0)=="."){
			els[i] = $D.getElementsByClassName(els[i].substring(1,els[i].length)); //返回数组
			
			if(els[i].length==1){
				els[i] = els[i][0];  //对象
			}
		}else{
			if(els[i].indexOf(".")>0){
				var tag = els[i].split(".");
				els[i] = $D.getElementsByClassName(tag[1],tag[0])[0];
			}else{
				els[i] = $D.get(els[i]);
			}
		}
	}
	
	if(els.length==1){
		return els[0]; //返回对象
	}else{
		return els;  //返回JSON数组
	}
}

/*
	说明：获取root下的子标签
	参数tag类型: string
	参数root类型: object || string
	返回：array
	例子：$("div"),$("input[name=name]"),$("div[attr=attr]"),$("div.classname")
*/
var $g = function(tag,root){
	
	root = root ? root : document;
	
	if(Shoes.lang.isString(root)){
		root = $(root);
	}
	var attrPattern = /([a-z|A-Z]+)\[([a-z|A-Z|0-9|_-]+)=[\'|\"]?(.*)[\'|\"]?\]/g,
		mat = tag.match(attrPattern),
		tagArr = new Array(),
		match;
	
	if(mat){
		var tags,attr;
		for(var i=0, n = mat.length; i<n; i++){
			match = mat[i].match(/\w+/g); //如果有特殊字符？
			tags = root.getElementsByTagName(match[0]);
			for(var j=0, m = tags.length; j< m ; j++){
				attr = tags[j].getAttribute(match[1]);
				if(attr){
					//如果属性值一样
					if(match[2]==attr){
						tagArr.push(tags[j]);
					}
				}
			}
		}
	}else if(tag.indexOf(".")>-1){
		tag = tag.split(".");
		tagArr = $D.getElementsByClassName(tag[1],tag[0],root);
	}else{
		tagArr = root.getElementsByTagName(tag);
	}
	
	return tagArr;
}

//获得子节点
var _getChildNodes = function (el) {
    var nodes = [];
    var childNodes = el.childNodes;

    for (var i = 0, len = childNodes.length; i < len; ++i) {
        if (childNodes[i].nodeType == 1) {
            nodes[nodes.length] = childNodes[i];
        }
    }

    return nodes;
};

if (!Array.prototype.indexOf) {
    Array.prototype.indexOf = function(C, B) {
        if (B == null) {
            B = 0
        } else {
            if (B < 0) {
                B = Math.max(0, this.length + B)
            }
        } for (var A = B; A < this.length; A++) {
            if (this[A] === C) {
                return A
            }
        } return -1
    }
} if (!Array.prototype.lastIndexOf) {
    Array.prototype.lastIndexOf = function(C, B) {
        if (B == null) {
            B = this.length - 1
        } else {
            if (B < 0) {
                B = Math.max(0, this.length + B)
            }
        } for (var A = B; A >= 0; A--) {
            if (this[A] === C) {
                return A
            }
        } return -1
    }
} if (!Array.prototype.forEach) {
    Array.prototype.forEach = function(C, D) {
        var A = this.length;
        for (var B = 0; B < A; B++) {
            C.call(D, this[B], B, this)
        }
    }
} if (!Array.prototype.filter) {
    Array.prototype.filter = function(D, E) {
        var A = this.length;
        var C = [];
        for (var B = 0; B < A; B++) {
            if (D.call(E, this[B], B, this)) {
                C.push(this[B])
            }
        } return C
    }
} if (!Array.prototype.map) {
    Array.prototype.map = function(D, E) {
        var A = this.length;
        var C = [];
        for (var B = 0; B < A; B++) {
            C.push(D.call(E, this[B], B, this))
        } return C
    }
} if (!Array.prototype.some) {
    Array.prototype.some = function(C, D) {
        var A = this.length;
        for (var B = 0; B < A; B++) {
            if (C.call(D, this[B], B, this)) {
                return true
            }
        } return false
    }
} if (!Array.prototype.every) {
    Array.prototype.every = function(C, D) {
        var A = this.length;
        for (var B = 0; B < A; B++) {
            if (!C.call(D, this[B], B, this)) {
                return false
            }
        } return true
    }
} Array.prototype.contains = function(A) {
    return this.indexOf(A) != -1
};
Array.prototype.copy = function(A) {
    return this.concat()
};
Array.prototype.insertAt = function(B, A) {
    this.splice(A, 0, B)
};
Array.prototype.insertBefore = function(C, B) {
    var A = this.indexOf(B);
    if (A == -1) {
        this.push(C)
    } else {
        this.splice(A, 0, C)
    }
};
Array.prototype.removeAt = function(A) {
    this.splice(A, 1)
};
Array.prototype.remove = function(B) {
    var A = this.indexOf(B);
    if (A != -1) {
        this.splice(A, 1)
    }
};
if (!String.prototype.toQueryParams) {
    String.prototype.toQueryParams = function() {
        var F = {};
        var G = this.split("&");
        var D = /([^=]*)=(.*)/;
        for (var B = 0; B < G.length; B++) {
            var A = D.exec(G[B]);
            if (!A) {
                continue
            } var C = decodeURIComponent(A[1]);
            var E = A[2] ? decodeURIComponent(A[2]) : undefined;
            if (F[C] !== undefined) {
                if (F[C].constructor != Array) {
                    F[C] = [F[C]]
                } if (E) {
                    F[C].push(E)
                }
            } else {
                F[C] = E
            }
        } return F
    }
} if (!String.prototype.trim) {
    String.prototype.trim = function() {
        var A = /^\s+|\s+$/g;
        return function() {
            return this.replace(A, "")
        }
    } ()
} if (!String.prototype.replaceAll) {
    String.prototype.replaceAll = function(B, A) {
        return this.replace(new RegExp(B, "gm"), A)
    }
}
Math.randomInt = function(A) {
    return Math.floor(Math.random() * (A + 1))
};
(function(){
		  
	var ua = navigator.userAgent.toLowerCase();
	
	var opera = ua.indexOf("opera")!=-1,
		safari = ua.indexOf("safari")!=-1,
		gecko = !opera && !safari && ua.indexOf("gecko")>-1,
		ie = !opera && ua.indexOf("msie")!=-1,
		ie6 = !opera && ua.indexOf("msie 6")!=-1,
		ie7 = !opera && ua.indexOf("msie 7")!=-1;
		
	Shoes.namespace("Tools");
	
	Shoes.Tools = {
		isOpera : opera,
		isSafari : safari,
		isGecko : gecko,
		isIE : ie,
		isIE6 : ie6,
		isIE7 : ie7,
		getCookie : function (name){
			var cookie=document.cookie.match("(?:^|;)\\s*" + name + "=([^;]*)");
			return cookie ? decodeURI(cookie[1]) : "";
		},
		setCookie : function (name,value,expires,domain,path){
			value = encodeURI(value);
			value += (domain) ? "; domain=" + domain : "";
			value += (path) ? "; path=" + path : "";
			if(expires){
				var expire=new Date();
				expire.setTime( expire.getTime() + (expires*86400000) );
				value += "; expires="+expire.toGMTString()
			}
			document.cookie = name + "=" + value;
		},
		removeCookie : function (name){
			this.setCookie(name,"",-1);
		},
		isValidEmail : function(email){
			if (email.search(/[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/) != -1){
				return true;
			}else{
				return false;
			}
		},
		trim:function(s){
			return A.replace(/(^\s*)|(\s*$)/g,"")
		},
		isHttp: function(s){
		    try{
		        return /(http:\/\/)?([\w-]+\.)+[\w-]+(\/[\w-\.\/?%&=]*)?/.test(s);
		    }catch(e){
		        return false;
		    }
		},
		isNumber : function(s){
		    try{
		        return /^\d+$/.test(s);
		    }catch(e){
		        return false;
		    }
		}
	};
	
})();

Shoes.common={
	trim:function (A){
		return A.replace(/(^\s*)|(\s*$)/g,"")
	},
	escapeHTML:function (B){
		var C=document.createElement("div");
		var A=document.createTextNode(B);
		C.appendChild(A);
		return C.innerHTML;
	},
	unescapeHTML:function (A){
		var B=document.createElement("div");
		B.innerHTML=A.replace(/<\/?[^>]+>/gi,"");
		return B.childNodes[0]?B.childNodes[0].nodeValue:""
	},
	stripTags:function (A){
		return A.replace(/<\/?[^>]+>/gi,"")
	},
	toArray:function (B,D){
		var C=[];
		for(var A=D||0;A<B.length;A++){
			C[C.length]=B[A]
		}return C
	},
	applyIf:function (C,A){
		if(C&&A&&typeof A=="object"){
			for(var B in A){
				if(!YAHOO.lang.hasOwnProperty (C,B)){
					C[B]=A[B]
				}
			}
		}return C
	},
	apply:function (C,A){
		if(C&&A&&typeof A=="object"){
			for(var B in A){
				C[B]=A[B]
			}
		}return C
	},
	formatMessage:function (D,A,B){
		var C=/\{([\w-]+)?\}/g;
		return function (G,E,F){
			return G.replace(C,function (H,I){
				return F?F(E[I],I):E[I]
			})
		}
	}(),
	parseUri:(function (){
		var B=["source","prePath","scheme","username","password","host","port","path","dir","file","query","fragment"];
		var A=/^((?:([^:\/?#.]+):)?(?:\/\/)?(?:([^:@]*):?([^:@]*)?@)?([^:\/?#]*)(?::(\d*))?)((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?/;
		return function (F){
			var E={};
			var C=A.exec(F);
			for(var D=0;D<C.length;++D){
				E[B[D]]=(C[D]?C[D]:"")
			}return E
		}
	})()
};
Shoes.applyIf=Shoes.common.applyIf;
Shoes.apply=Shoes.common.apply;
(function(){
	Shoes.namespace("SimpleTab");
	Shoes.SimpleTab = function(el) {
		this.activeTab = 0;
		this.Content = "Content";
		this.id = el;
		if (Shoes.lang.isString(el) || !el) { // id or null
			el = $(el);
		}

		var tabs = this;
		
		var items = el.getElementsByTagName("span");
		
		for(var i=0;i<items.length;i++){
			$E.on(items[i],"mouseover",function(ev,el){
				$D.removeClass(items[tabs.activeTab].parentNode,"selected");
				$D.addClass(this.parentNode,"selected");
				var tabContent = $D.getElementsByClassName(tabs.id+tabs.Content);
				$D.setStyle(tabContent[tabs.activeTab],"display","none");
				$D.setStyle(tabContent[el.idx],"display","block");
				tabs.activeTab = el.idx;
				return false;
			},{idx:i});
			$E.on(items[i],"click",function(ev,el){
				return false;
			},{idx:i})
		}
	}
})();
//选项卡
(function(){
	Shoes.namespace("Tab");
	//cfg: id,activeIndex,tabContentClass,tabNavClass,isAjax,returnFalse
	Shoes.Tab = function(cfg){
		if(!cfg.id){return;}
		var tab;
		var activeIndex = 0;
		var activeTab = null;
		if (Shoes.lang.isString(cfg.id)) {
			tab = $(cfg.id);
		}
		if(cfg.activeIndex){
			activeIndex = cfg.activeIndex;
		}
		if(cfg.tabNavClass!=null||cfg.tabNavClass!=""){
			this.tabNavClass = cfg.tabNavClass;
		}
		if(cfg.tabContentClass!=null||cfg.tabContentClass!=''){
			this.tabContentClass = cfg.tabContentClass;
		}
		var tabs = this;
		var ul = $D.getElementsByClassName(this.tabNavClass,"ul",tab)[0];
		var items = ul.getElementsByTagName("li");
		
		for(var i=0;i<items.length;i++){
			var tabCon = $D.getElementsByClassName(items[i].tabContentClass,"div",tab);
			if(activeIndex==i){
				$D.removeClass(tabCon[i],"hidden");
				$D.addClass(items[i],"active");
			}else{
				$D.addClass(tabCon[i],"hidden");
				$D.removeClass(items[i],"active");
			}
			$E.on(items[i],"mouseover",function(ev,el){
				$D.removeClass(items[activeIndex],"active");
				$D.addClass(this,"active");
				//显示当前选项卡的内容
				var tabContent = $D.getElementsByClassName(tabs.tabContentClass,"div",tab);
				$D.addClass(tabContent[activeIndex],"hidden");
				$D.removeClass(tabContent[el.idx],"hidden");
				activeIndex = el.idx;
				//判断如果有链接是否需要跳转
//				if(this.getElementsByTagName("a").length>0){
//					this.getElementsByTagName("a")[0].onclick = function(){
//						return tabs.returnFalse;
//					}
//				}
			},{idx:i});
		}
	}
	Shoes.Tab.prototype = {
		//显示内容的样式集合
		tabContentClass : "tab-content",
		//显示选项卡片标题的样式集合
		tabNavClass : "tab-nav",
		//是否有包含ajax
		isAjax : false,
		//链接是否失效：false表示失效;true表示有效，点击将会跳转
		returnFalse : false,
		activeIndex : 0,
		GetActiveIndex:function(){return this.activeIndex;}
	}
})();

/*
*/
function SimpleTab(el,attrs){
	if(!el)return;
	attrs = attrs || {};
	if(arguments.length==1 && !typeof(el)=="string" && !el.nodeName){
		attrs = el;
		el = attrs.element;
	}
	var activeIndex = 0;
	var activeTab = null;
	var queue = {};
	var TAB_PARENT_CLASSNAME = "tab-nav";
	var TAB_ACTIVE_CLASSNAME = "active";
	var CONTENT_PARENT_CLASSNAME = "tab-content";
	var LABEL_TAGNAME = "a";
	var ACTIVE_TAB = "activeTab";
	var self = this;
	this.tabList = [];

	if(attrs.index){
		activeIndex = attrs.index;
	}
	if(attrs.activeTab){
		activeTab = attrs.activeTab;
	}
	if(attrs.TAB_PARENT_CLASSNAME){
		TAB_PARENT_CLASSNAME = attrs.TAB_PARENT_CLASSNAME;
	}
	if(attrs.CONTENT_PARENT_CLASSNAME){
		CONTENT_PARENT_CLASSNAME = attrs.CONTENT_PARENT_CLASSNAME;
	}
	if(attrs.LABEL_TAGNAME){
		LABEL_TAGNAME = attrs.LABEL_TAGNAME;
	}
	
	if(attrs.TAB_ACTIVE_CLASSNAME){
		TAB_ACTIVE_CLASSNAME = attrs.TAB_ACTIVE_CLASSNAME;
	}
	
	this.set = function(key,value){
		queue[key]=value;
		return queue;
	}
	
	this.get = function(key){
		return queue[key];
	}
	
	function ChangeTab(oldtab,newtab){
		if(oldtab){
			var oTab = oldtab.tab,
				otab = oTab.tabEl;
			$D.removeClass(otab,TAB_ACTIVE_CLASSNAME);
			$D.addClass(oldtab.contentEl,"hidden");
			$D.removeClass(otab.getElementsByTagName(oTab.LABEL_TAGNAME)[0],"selected");
		}
		if(newtab){
			var nTab = newtab.tab,
				ntab = nTab.tabEl;
			$D.addClass(ntab,TAB_ACTIVE_CLASSNAME);
			$D.removeClass(newtab.contentEl,"hidden");
			$D.addClass(ntab.getElementsByTagName(nTab.LABEL_TAGNAME)[0],"selected");
		}
	};
	
	function init(){
		self.set("tabs",getChildNodes($D.getElementsByClassName(TAB_PARENT_CLASSNAME,"ul",el)[0]));
		self.set("contentElements",getChildNodes($D.getElementsByClassName(CONTENT_PARENT_CLASSNAME,"div",el)[0]));
		
		var tabs = self.get("tabs");
		var contentElements = self.get("contentElements");
		var attr;

		for(var i=0;i<tabs.length;i++){
			attr = {};
			if(LABEL_TAGNAME){
				attr.LABEL_TAGNAME = LABEL_TAGNAME;
			}
			if(contentElements[i]){
				attr.contentEl = contentElements[i];
			}
			if(attrs.callback){
				attr.callback = attrs.callback;
			}
			if(attrs.eventType){
				attr.eventType = attrs.eventType;
			}
			var tab = new Tab(tabs[i],attr);
			self.tabList.push(tab);
			if(i == activeIndex){
				self.set(ACTIVE_TAB,{
					tab:tab,
					contentEl:contentElements[i],
					callback:attrs.callback,
					eventType:attrs.eventType
				});
				
				self.set("oldTab",self.get(ACTIVE_TAB));
			}
		}
	};

	function Tab(el, attr){
		if(!el)return;
		attr = attr || {};
		if(arguments.length==1 && !typeof(el)=="string" && !el.nodeName){
			attr = el;
			el = attr.element;
		}
		this.tabEl = el;
		this.contentEl = attr.contentEl;
		this.LABEL_TAGNAME = "a";
		this.LABEL_CLASSNAME = "selected";
		this.eventType = "click";
		
		if(attr.LABEL_TAGNAME){
			this.LABEL_TAGNAME = attr.LABEL_TAGNAME;
		}
		if(attr.LABEL_CLASSNAME){
			this.LABEL_CLASSNAME = attr.LABEL_CLASSNAME;
		}
		if(attr.callback){
			this.callback = attr.callback;
		}
		
		if(attr.eventType){
			this.eventType = attr.eventType;
		}
		
		var label = el.getElementsByTagName(this.LABEL_TAGNAME)[0];
		var _this = this;
		
		if(this.LABEL_TAGNAME == "a"&&label.href.indexOf("#")>-1){
			attr.contentEl = $(label.href.substring(label.href.indexOf("#")+1,label.href.length));
		}
		
		var addEvent = function(e){
			e && $E.preventDefault(e);
			var newtab = {};
			var oldtab = self.get(ACTIVE_TAB);
			newtab.tab = _this;
			newtab.contentEl = attr.contentEl;
			ChangeTab(oldtab,newtab);
			self.set("oldTab",oldtab);
			self.set(ACTIVE_TAB,newtab);
			if(_this.callback){
				_this.callback.call(this);
			}
		}
		var url = window.location.href;
		if(url.indexOf("#")!==-1){
			var contentEl = attr.contentEl,
				contentId = url.substring(url.indexOf("#")+1,url.length);
			if(contentEl.id === contentId){
				addEvent();
			}
		}
		
		$E.on(label,this.eventType,addEvent);
	}
	
	this.setActive = function(id){
		var contentElements = self.get("contentElements"),tab_index=0,currentContent,currentTab;
		for(var i=0,len = contentElements.length;i<len;i++){
			if(contentElements[i].id===id){
				tab_index=i;
				currentContent = contentElements[i];
				currentTab = self.tabList[i];
				break;
			}
		}
		
		var newtab = {},oldtab = self.get(ACTIVE_TAB);
		newtab.tab = currentTab;
		newtab.contentEl = currentTab.contentEl;
		ChangeTab(oldtab,newtab);
		self.set("oldTab",oldtab);
		self.set(ACTIVE_TAB,newtab);
		if(currentTab.callback){
			currentTab.callback.call(this);
		}
	}
	
	init();
}

var getChildNodes = function(el) {
	var nodes = [];
	var childNodes = el.childNodes;
	for (var i = 0, len = childNodes.length; i < len; ++i) {
		if (childNodes[i].nodeType == 1) {
			nodes[nodes.length] = childNodes[i];
		}
	}
	return nodes;
};

/*
	onchange事件
	target:blank
	
*/
function SelectOption(attr){
	if(!attr.el)return;
	var el;
	if(typeof(attr.el)=="string"){
		el = $(attr.el);
	}else{
		el = attr.el;
	}
	var flag = false;
	var doc = document;
	var elements = [];
	var showEl = null;

	if(el.length){
		elements = el;
	}else{
		elements.push(el);
	}
	
	//如果是单击事件，增加一个点击文档判断
	document.body.onclick = function(){
		if(flag && showEl){//有显示对象
			var ul = showEl.getElementsByTagName("ul")[0];//找到列表
			$D.setStyle(ul,"display","none");
			flag = false;
		}
	}
	//鼠标经过
	if(attr.eventype == "mouseover"){
		$E.on(elements,"mouseover",function(){
			var ul = this.getElementsByTagName("ul")[0];//找到列表
			$D.setStyle(ul,"display","block");
		});
		$E.on(elements,"mouseout",function(){
		    var ul = this.getElementsByTagName("ul")[0];//找到列表
			$D.setStyle(ul,"display","none");
		});
	}else{
		$E.on(elements,"click",function(e){
			var ul = this.getElementsByTagName("ul")[0];//找到列表
			$D.setStyle(ul,"display","block");
			flag = true;
			showEl = this;
			$E.stopEvent(e);
		});
	}
	
	//多个，配置一样，不同的就单独定义，多个连续渲染，则不赋值
	var a = elements.length;
	for(var i=0;i<a;i++){
		var ul = elements[i].getElementsByTagName("ul")[0];//找到列表
		if(!ul)continue;
		var list = ul.getElementsByTagName("li");
		var b = list.length;
		//查找列表
		var bydefault;
		for(var j=0;j<b;j++){
			if($D.hasClass(list[j],"by-default") && !bydefault){//判断是否有默认选择，如果多个选择，默认第一个
				bydefault = list[j];
			}
			var alink = list[j].getElementsByTagName("a")[0];
			(function(){
			var oUl = ul;
			var oList = list;
			var n = i;
			var El = elements[i];

			$E.on(alink,"click",function(e){
				//单击选择，如果地址包含#号，则#号后面为选择的值
				for(var c=0;c<b;c++){//使用全部清除，防止写多个by-default
					$D.removeClass(oList[c],"by-default");
				}
				var parentNode = this.parentNode;
				$D.addClass(parentNode, "by-default");
				
				//1.替换已经选中的
				var bydef = $D.getElementsByClassName("by-default","span",El)[0];
				if(bydef){
					bydef.innerHTML = "<em>"+this.innerHTML +"</em>";
				}else{
					var span = doc.createElement("span");
					span.className = "select-item";
					span.innerHTML = "<span class='by-default'><em>"+this.innerHTML+"</em></span>";
					$D.insertBefore(span,oUl);
				}
				//4.隐藏列表
				if(!$D.hasClass(oUl,"hidden")){
					$D.setStyle(oUl,"display","none");
				}else{
					$D.addClass(oUl,"hidden");
				}
				//2.如果是#号，则获取#号后面的值
				var href = this.href,value="";
				if(href.indexOf("#")!=-1){//取出后面的值
					value = href.substring(href.indexOf("#")+1,href.length);
				}
				if(value!=""){
					if(attr.option){
						attr.option[n].value = value;
					}
				}else{
					//3.是否是弹出窗口，如果包含#号就不需要弹窗
					if(attr.target){
						this.target = "_"+attr.target;
					}
				}
				if(attr.optionCallBack){
					attr.optionCallBack[n]();
				}
				if(href.indexOf("#")!=-1){
					$E.stopEvent(e);
				}
			});
			
			$E.on(alink, "mouseover", function(){
				$D.addClass(this, "select-over");
			});
			$E.on(alink, "mouseout", function(){
				$D.removeClass(this, "select-over");
			});
			
			})();
		}
		
		if(bydefault){
			var alink = bydefault.getElementsByTagName("a")[0];
			var selectItem = $D.getElementsByClassName("by-default","span",elements[i])[0];
			if(selectItem){
				selectItem.innerHTML = "<em>"+alink.innerHTML +"</em>";
			}else{				
				var span = doc.createElement("span");
				span.className = "select-item";
				span.innerHTML = "<span class='by-default'><em>"+alink.innerHTML+"</em></span>";
				$D.insertBefore(span,ul);
			}
			var href = alink.href,value="";
			if(href.indexOf("#")!=-1){//取出后面的值
				value = href.substring(href.indexOf("#")+1,href.length);
			}
			if(value!=""){
				if(attr.option){
					attr.option[i].value = value;
				}
			}else{
				//3.是否是弹出窗口，如果包含#号就不需要弹窗
				if(attr.target){
					alink.target = "_"+attr.target;
				}
			}
		}
		bydefault = null;
	}
}

(function() {

    Shoes.namespace("OnlineUser");

    Shoes.OnlineUser = function() {
        this.userid = -1;
        this.username = "";
        this.companyid = 0;
		this.wholeuserid = -1;
		this.wholeusername = "";
		this.wholecompanyid = 0;

        var cookie = unescape(Shoes.Tools.getCookie("user"));
		var wholecookie = unescape(Shoes.Tools.getCookie("wholeuser"));
        if (cookie != "") {
            var u = cookie.split('&');
            if (u.length == 4) {
                this.userid = u[0].substring(u[0].indexOf("=") + 1, u[0].length);
                this.username = u[1].substring(u[1].indexOf("=") + 1, u[1].length);
                this.groupid = u[3].substring(u[3].indexOf("=") + 1, u[3].length);
            }
        }
		if (wholecookie != "") {
            var wu = wholecookie.split('&');
            if (wu.length == 4) {
                this.wholeuserid = wu[0].substring(wu[0].indexOf("=") + 1, wu[0].length);
				this.wholeusername = wu[1].substring(wu[1].indexOf("=") + 1, wu[1].length);
                this.wholegroupid = wu[3].substring(wu[3].indexOf("=") + 1, wu[3].length);
            }
        }
    };

})();
var user = new Shoes.OnlineUser();

function ServiceTab(){
	var serviceTab = $D.getElementsByClassName("item-tab","ul",$("service"))[0];
	var li = serviceTab.getElementsByTagName("li");
	var tabContent = $D.getElementsByClassName("item-tab-content","div",$("service"));
	var selectedId = 0;
	for(var i=0;i<li.length;i++){
		$E.on(li[i],"mouseover",function(ev,el){
			$D.removeClass(li[selectedId],"selected");
			$D.addClass(this,"selected");
			$D.setStyle(tabContent[selectedId],"display","none");
			$D.setStyle(tabContent[el.idx],"display","block");
			selectedId = el.idx;
		},{idx:i})
	}
}

Shoes.changeValCode = function(imgid, objid) {
    imgid = $(imgid);
    var src = imgid.src;
    imgid.src = src + '&r=' + Math.random();
    setTimeout(function() {
    if (objid) $(objid).focus();
    }, 50);
}

Shoes.isExist = function(type, value, existcallback, notcallback) {
    var flag = false;
    var url = "/checkexist.htm?type=" + type + "&value=" + value + "&rnd=" + Math.round(Math.random() * 10000);
    YAHOO.util.Connect.asyncRequest("GET", url, {
        success: function(req) {
            if (req.responseText == "1") {
                existcallback && existcallback();
            } else {
                notcallback && notcallback();
            }
        }, failure: function(req) {
        }
    });
}

var searchTypeList = [
	{ searchType: "sale", tips: "请输入产品名称", action: "http://www.shoes.net.cn/sale/search.htm", searchId: "4" },
	{ searchType: "buy", tips: "请输入产品名称", action: "http://www.shoes.net.cn/buy/search.htm", searchId: "5" },
	{searchType:"company",tips:"请输入公司名称",action:"http://www.shoes.net.cn/company/search.htm",searchId:"3"},
	{searchType:"product",tips:"请输入产品名称",action:"http://www.shoes.net.cn/product/search.htm",searchId:"2"},
	{searchType:"brand",tips:"请输入品牌名称",action:"http://brand.shoes.net.cn/search.htm",searchId:"7"},
	{searchType:"news",tips:"请输入关键字",action:"http://www.shoes.net.cn/news/search.htm",searchId:"6"},
	{searchType:"job",tips:"请输入关键字",action:"http://www.shoes.net.cn/hr/companyList.html",searchId:"8"}
];

function SearchBar(barId){
	if(!barId||barId=="")return;
	var searchTab = $(barId).getElementsByTagName("li");
	var hotkeyword = $("hotsearch").getElementsByTagName("dd");
	var selectedId = 0;
	var searchType = $("searchType").value||"";
	var keyword = $("keyword");
	var oldsearchId = 0;
	
	for(var i=0;i<searchTab.length;i++){
		$E.on(searchTab[i], "click", function(ev, el) {
		    $D.removeClass(searchTab[selectedId], "selected");
            $D.addClass(this, "selected");
			$D.addClass($("keyword_"+oldsearchId),"hidden");
			
			var oldSearchType = null;
			for(var i=0; i<searchTypeList.length;i++){
				if(oldsearchId == searchTypeList[i].searchId){
					oldSearchType = searchTypeList[i];
					break;
				}
			}
            selectedId = el.idx;
			
            searchType = searchTab[selectedId].getAttribute("searchType");
            $("searchType").value = searchType;
			
			for(var i=0; i<searchTypeList.length;i++){
				if(searchTypeList[i].searchType==searchType){
					
					$D.removeClass($("keyword_"+searchTypeList[i].searchId),"hidden");
					$("searchForm").action = searchTypeList[i].action;
					oldsearchId = searchTypeList[i].searchId;
					
					if(oldSearchType.tips==keyword.value){
						keyword.value = searchTypeList[i].tips;
					}else if(keyword.value.trim()==""){
						keyword.value = searchTypeList[i].tips;
					}
					break;
				}
			}
		}, { idx: i });
		if(searchTab[i].getAttribute("searchType")==searchType){
			$D.removeClass(searchTab[0],"selected");
			$D.addClass(searchTab[i],"selected");
			$D.addClass(hotkeyword[0],"hidden");
			for(var j=0; j<searchTypeList.length;j++){
				if(searchTypeList[j].searchType==searchType){
					$D.removeClass($("keyword_"+searchTypeList[j].searchId),"hidden");
					keyword.value = searchTypeList[j].tips;
					$("searchForm").action = searchTypeList[j].action;
					oldsearchId = searchTypeList[j].searchId;
					break;
				}
			}
			selectedId = i;
		}
	}
	
	$E.on(keyword,"focus",function(){
		for(var i = 0;i<searchTypeList.length;i++){
			if(searchTypeList[i].searchType == searchType){
				if(this.value==searchTypeList[i].tips){
					this.value = "";
					$D.setStyle(this,"color","#000000");
					break;
				}
			}
		}
	});
	$E.on(keyword,"blur",function(){
		for(var i = 0;i<searchTypeList.length;i++){
			if(searchTypeList[i].searchType == searchType){
				if(this.value.trim()==""){
					this.value = searchTypeList[i].tips;
					$D.setStyle(this,"color","#CCCCCC");
					break;
				}
			}
		}
	})
}

function doSearch(){
	var key = $("keyword").value;
	if (key.length > 30) {
		alert("您输入的关键字过长！");
		return false;
	}
	if (key == "" || key.substring(0, 3) == "请输入") {
		alert("请输入关键字！");
		return false;
	}
	if (key.length < 2) {
		alert("关键字不能少于两个字！");
		return false;
	}
	$("searchForm").target="_blank";
}

function anti_spam(domain,in_email) {
  var out_email = "", i;

  for (i = 0; i < in_email.length; i++) {
    out_email += in_email.charAt(in_email.length - i - 1);
  }
  document.write("<a href=\"mailto:" + out_email +"@"+ domain + "\">" + out_email +"@"+ domain + "</a>");
}
///折叠
var accordion=function(){
	var tm=sp=10;
	function slider(n){this.nm=n; this.arr=[];}
	slider.prototype.init=function(t,c,k){
		var a,h,s,l,i; a=document.getElementById(t); this.sl=k?k:'';
		h=a.getElementsByTagName('dt'); s=a.getElementsByTagName('dd'); this.l=h.length;
		for(i=0;i<this.l;i++){var d=h[i]; this.arr[i]=d; d.onclick=new Function(this.nm+'.pro(this)'); if(c==i){$D.addClass(d,this.sl)}}
		l=s.length;
		for(i=0;i<l;i++){var d=s[i]; d.mh=d.offsetHeight; if(c!=i){d.style.height=0; $D.addClass(d,"hidden");}}
	}
	slider.prototype.pro=function(d){
		for(var i=0;i<this.l;i++){
			var h=this.arr[i], s=h.nextSibling; s=s.nodeType!=1?s.nextSibling:s; clearInterval(s.tm);
			if(h==d&&$D.hasClass(s,"hidden")){$D.removeClass(s,"hidden"); su(s,1); $D.addClass(h,this.sl);}
			else if(!$D.hasClass(s,"hidden")){su(s,-1); $D.removeClass(h,this.sl);}
		}
	}
	function su(c,f){c.tm=setInterval(function(){sl(c,f)},tm)}
	function sl(c,f){
		var h=c.offsetHeight, m=c.mh, d=f==1?m-h:h; c.style.height=h+(Math.ceil(d/sp)*f)+'px';
		c.style.opacity=h/m;
		c.style.filter='alpha(opacity='+h*100/m+')';
		if(f==1&&h>=m){clearInterval(c.tm)}else if(f!=1&&h==1){$D.addClass(c,"hidden"); clearInterval(c.tm)}
	}
	return{slider:slider}
}();


(function(){

var defConfig = {
	name : "",    //名称
	delay : null, //5秒后自动关闭，null表示没有自动关闭
	type : "image",  //默认格式是图片
	anim : false,  //是否使用动画
	top : 200,      //离顶部的距离
	direction : 0,   //0只显示左边，1只显示右边，2两边都显示
	expand : false,  //是否需要展开，如果是flash就不用了
	showCloseButton: false,  //显示关闭按钮
	autoExpand : false,  //自动展开
	data:{}
};

//合并参数
var mergeConfig = function(def, cfg){
	for(var p in def){
		if(p in cfg){
			def[p] = cfg[p];
		}
	}
	return def;
}

Shoes.Couplet = function(config){
	
	config = mergeConfig(defConfig, config || {});
	
	this.name = (config.name !== "") ? config.name : "C" + new Date();
	this.delay = config.delay;
	this.type = config.type;
	this.anim = config.anim;
	this.top = config.top;
	this.direction = config.direction;
	this.data = config.data;
	this.expand = config.expand;
	this.showCloseButton = config.showCloseButton;
	this.autoExpand = config.autoExpand;
	
	var couplet = this,
		D = document, 
		b = D.body, 
		//关闭按钮
		oClose = null, 
		oFragment = D.createDocumentFragment(), 
		//对联第一个
		oCouplet = D.createElement("div"),
		autoCollapsed = null,img1 = new Image(),img2 = new Image(),imgW,imgH,imgW2,imgH2;
	var alink;
		
	//获取第一张图片的高度宽度
	img1.src = this.data.imgUrl + "?t="+new Date();
	img1.onload = function(){
		imgW = img1.width;
		imgH = img1.height;
	};
	//获取第二张图片的高度宽度
	img2.src = this.data.imgUrl2 + "?t="+new Date();
	img2.onload = function(){
		imgW2 = img2.width;
		imgH2 = img2.height;
	};
	
	oCouplet.style.position = "absolute";
	oCouplet.style.zIndex = "999999";
	oCouplet.style.top = this.top + "px";
	
	//显示两边
	switch (this.direction){
		case 0://只显示左边
			oCouplet.id = "L"+this.name;
			oCouplet.style.left = "0px";
			break;
		case 1://只显示右边
			oCouplet.id = "R"+this.name;
			oCouplet.style.right = "0px";
			break;
	}
	//显示类型
	switch(this.type){
		case "image":
			alink = D.createElement("a");
			alink.target = "_blank";
			alink.href = this.data.url;
			this.img = new Image();
			this.img.src = this.data.imgUrl;
			alink.appendChild(this.img);
			oFragment.appendChild(alink);
			break;
		
		case "flash":
			var flashCode = "";
			break;
	}
	
	if(this.showCloseButton){
		oClose = D.createElement("div");
		oClose.style.cssText = "position:absolute;bottom:-24px;"+(this.direction===1?"right:0;":"left:0;")+"height:24px;line-height:24px;width:30px;text-align:center;cursor:pointer;";
		oClose.innerHTML = "关闭";
		oClose.onclick = function(){
			b.removeChild(oClose.parentNode);
		}
		oFragment.appendChild(oClose);
	}
	oCouplet.appendChild(oFragment);
	b.appendChild(oCouplet);
	
	this.autoClose = function(){
		//自动关闭
		couplet.interval = setTimeout(function(){
			b.removeChild(oCouplet);
		}, this.delay);
	}
	
	alink.onmouseover = function(){
		if(couplet.delay){
			clearTimeout(couplet.interval);
		}
		if(autoCollapsed){
			clearTimeout(autoCollapsed);
		}
		if(couplet.expand && couplet.type==="image"){
			setTimeout(function(){
			couplet.img.src = couplet.data.imgUrl2;
			couplet.img.width = imgW2;
			couplet.img.height = imgH2;
			},200);
		}
	}
	alink.onmouseout = function(){
		if(couplet.delay){
			couplet.autoClose();
		}
		if(couplet.expand && couplet.type==="image"){
			setTimeout(function(){
			couplet.img.src = couplet.data.imgUrl;
			couplet.img.width = imgW;
			couplet.img.height = imgH;
			},200);
		}
	}
	
	var Swap = function(){
	};
	
	//自动展开
	if(this.autoExpand){
		this.interval = setTimeout(function(){
			if(couplet.expand && couplet.type==="image"){
				couplet.img.src = couplet.data.imgUrl2;
				couplet.img.width = imgW2;
				couplet.img.height = imgH2;
			}
			//自动收缩
			autoCollapsed = setTimeout(function(){
				couplet.img.src = couplet.data.imgUrl;
				couplet.img.width = imgW;
				couplet.img.height = imgH;
				if(couplet.delay){
					couplet.autoClose();
				}
			},5000);
		}, 2000);
	}else{
		if(couplet.delay){
			this.autoClose();
		}
	}
	
}

})();

/*IE8有bug*/
function ScrollPic(scrollContId, arrLeftId, arrRightId, dotListId) {
    this.scrollContId = scrollContId;
    this.arrLeftId = arrLeftId;
    this.arrRightId = arrRightId;
    this.dotListId = dotListId;
    this.dotClassName = "dotItem";
    this.dotOnClassName = "dotItemOn";
    this.dotObjArr = [];
    this.pageWidth = 0;
    this.frameWidth = 0;
    this.speed = 10;
    this.space = 10;
    this.pageIndex = 0;
    this.autoPlay = true;
    this.autoPlayTime = 5;
    var _autoTimeObj, _scrollTimeObj, _state = "ready";
    this.stripDiv = document.createElement("DIV");
    this.listDiv01 = document.createElement("DIV");
    this.listDiv02 = document.createElement("DIV");
    if (!ScrollPic.childs) {
        ScrollPic.childs = []
    };
    this.ID = ScrollPic.childs.length;
    ScrollPic.childs.push(this);
    this.initialize = function() {
        if (!this.scrollContId) {
            throw new Error("必须指定scrollContId.");
            return
        };
        this.scrollContDiv = $(this.scrollContId);
        if (!this.scrollContDiv) {
            throw new Error("scrollContId不是正确的对象.(scrollContId = \"" + this.scrollContId + "\")");
            return
        };
        this.scrollContDiv.style.width = this.frameWidth + "px";
        this.scrollContDiv.style.overflow = "hidden";

        if (this.frameWidth <= _getChildNodes(this.scrollContDiv)[0].offsetWidth) {
			this.listDiv01.innerHTML = this.listDiv02.innerHTML = this.scrollContDiv.innerHTML;
			this.scrollContDiv.innerHTML = "";
			this.scrollContDiv.appendChild(this.stripDiv);
			this.stripDiv.appendChild(this.listDiv01);
			this.stripDiv.appendChild(this.listDiv02);
			this.stripDiv.style.overflow = "hidden";
			this.stripDiv.style.zoom = "1";
			this.stripDiv.style.width = "32766px";
			this.listDiv01.style.cssText += "float:left";
			this.listDiv02.style.cssText += "float:left";
		
			$E.on(this.scrollContDiv, "mouseover", Function("ScrollPic.childs[" + this.ID + "].stop()"));
			$E.on(this.scrollContDiv, "mouseout", Function("ScrollPic.childs[" + this.ID + "].play()"));
			if (this.arrLeftId) {
				this.arrLeftObj = $(this.arrLeftId);
				if (this.arrLeftObj) {
					$E.on(this.arrLeftObj, "mousedown", Function("ScrollPic.childs[" + this.ID + "].rightMouseDown()"));
					$E.on(this.arrLeftObj, "mouseup", Function("ScrollPic.childs[" + this.ID + "].rightEnd()"));
					$E.on(this.arrLeftObj, "mouseout", Function("ScrollPic.childs[" + this.ID + "].rightEnd()"))
				}
			};
			if (this.arrRightId) {
				this.arrRightObj = $(this.arrRightId);
				if (this.arrRightObj) {
					$E.on(this.arrRightObj, "mousedown", Function("ScrollPic.childs[" + this.ID + "].leftMouseDown()"));
					$E.on(this.arrRightObj, "mouseup", Function("ScrollPic.childs[" + this.ID + "].leftEnd()"));
					$E.on(this.arrRightObj, "mouseout", Function("ScrollPic.childs[" + this.ID + "].leftEnd()"))
				}
			};
			if (this.dotListId) {
				this.dotListObj = $(this.dotListId);
				if (this.dotListObj) {
					var pages = Math.round(this.listDiv01.offsetWidth / this.frameWidth + 0.4),
					i,
					tempObj;
					for (i = 0; i < pages; i++) {
						tempObj = document.createElement("span");
						this.dotListObj.appendChild(tempObj);
						this.dotObjArr.push(tempObj);
						if (i == this.pageIndex) {
							tempObj.className = this.dotClassName
						} else {
							tempObj.className = this.dotOnClassName
						};
						tempObj.title = "第" + (i + 1) + "页";
						$E.on(tempObj, "click", Function("ScrollPic.childs[" + this.ID + "].pageTo(" + i + ")"))
					}
				}
			};
			if (this.autoPlay) {
				this.play()
			}
			}
    };
    this.leftMouseDown = function() {
        if (_state != "ready") {
            return
        };
        _state = "floating";
        _scrollTimeObj = setInterval("ScrollPic.childs[" + this.ID + "].moveLeft()", this.speed)
    };
    this.rightMouseDown = function() {
        if (_state != "ready") {
            return
        };
        _state = "floating";
        _scrollTimeObj = setInterval("ScrollPic.childs[" + this.ID + "].moveRight()", this.speed)
    };
    this.moveLeft = function() {
        if (this.scrollContDiv.scrollLeft + this.space >= this.listDiv01.scrollWidth) {
            this.scrollContDiv.scrollLeft = this.scrollContDiv.scrollLeft + this.space - this.listDiv01.scrollWidth
        } else {
            this.scrollContDiv.scrollLeft += this.space
        };
        this.accountPageIndex()
    };
    this.moveRight = function() {
        if (this.scrollContDiv.scrollLeft - this.space <= 0) {
            this.scrollContDiv.scrollLeft = this.listDiv01.scrollWidth + this.scrollContDiv.scrollLeft - this.space;
        } else {
            this.scrollContDiv.scrollLeft -= this.space
        };
        this.accountPageIndex()
    };
    this.leftEnd = function() {
        if (_state != "floating") {
            return
        };
        _state = "stoping";
        clearInterval(_scrollTimeObj);
        var fill = this.pageWidth - this.scrollContDiv.scrollLeft % this.pageWidth;
        this.move(fill)
    };
    this.rightEnd = function() {
        if (_state != "floating") {
            return
        };
        _state = "stoping";
        clearInterval(_scrollTimeObj);
        var fill = -this.scrollContDiv.scrollLeft % this.pageWidth;
        this.move(fill)
    };
    this.move = function(num, quick) {
        var thisMove = num / 5;
        if (!quick) {
            if (thisMove > this.space) {
                thisMove = this.space
            };
            if (thisMove < -this.space) {
                thisMove = -this.space
            }
        };
        if (Math.abs(thisMove) < 1 && thisMove != 0) {
            thisMove = thisMove >= 0 ? 1 : -1
        } else {
            thisMove = Math.round(thisMove)
        };
        var temp = this.scrollContDiv.scrollLeft + thisMove;
        if (thisMove > 0) {
            if (this.scrollContDiv.scrollLeft + thisMove >= this.listDiv01.scrollWidth) {
                this.scrollContDiv.scrollLeft = this.scrollContDiv.scrollLeft + thisMove - this.listDiv01.scrollWidth
            } else {
                this.scrollContDiv.scrollLeft += thisMove
            }
        } else {
            if (this.scrollContDiv.scrollLeft - thisMove <= 0) {
                this.scrollContDiv.scrollLeft = this.listDiv01.scrollWidth + this.scrollContDiv.scrollLeft - thisMove
            } else {
                this.scrollContDiv.scrollLeft += thisMove
            }
        };
        num -= thisMove;
        if (Math.abs(num) == 0) {
            _state = "ready";
            if (this.autoPlay) {
                this.play()
            };
            this.accountPageIndex();
            return
        } else {
            this.accountPageIndex();
            setTimeout("ScrollPic.childs[" + this.ID + "].move(" + num + "," + quick + ")", this.speed)
        }
    };
    this.next = function() {
        if (_state != "ready") {
            return
        };
        _state = "stoping";
        this.move(this.pageWidth, true)
    };
    this.play = function() {
        if (!this.autoPlay) {
            return
        };
        clearInterval(_autoTimeObj);
        _autoTimeObj = setInterval("ScrollPic.childs[" + this.ID + "].next()", this.autoPlayTime * 1000)
    };
    this.stop = function() {
        clearInterval(_autoTimeObj)
    };
    this.pageTo = function(num) {
        if (_state != "ready") {
            return
        };
        _state = "stoping";
        var fill = num * this.frameWidth - this.scrollContDiv.scrollLeft;
        this.move(fill, true)
    };
    this.accountPageIndex = function() {
        this.pageIndex = Math.round(this.scrollContDiv.scrollLeft / this.frameWidth);
        if (this.pageIndex > Math.round(this.listDiv01.offsetWidth / this.frameWidth + 0.4) - 1) {
            this.pageIndex = 0
        };
        var i;
        for (i = 0; i < this.dotObjArr.length; i++) {
            if (i == this.pageIndex) {
                this.dotObjArr[i].className = this.dotClassName
            } else {
                this.dotObjArr[i].className = this.dotOnClassName
            }
        }
    }
};



 (function() {
    var defConfig = {
        mode: "none",
        duration: .5,
        delay: 5000,
        effect: "none",
        direction: "E",
        method: YAHOO.util.Easing.easeOut,
        hasTriggle: true,
        autoplay: true
    };
    var Merge = function(def, cfg) {
        if (def && cfg && typeof(cfg) == "object") {
            for (var c in def) {
                if (cfg[c]) {
                    def[c] = cfg[c]
                }
            }
        }
        return def
    };
    var SlidePlayer = function(el, config) {
        if (typeof(el) === "string") {
            el = $(el)
        }
        this.config = Merge(defConfig, config);
        var slide = el.getElementsByTagName("ul")[0],
        slides = slide.getElementsByTagName("li"),
        triggles = [],
        len = slides.length,
        doc = document,
        current,
        index = 0,
        autoplay = this.config.autoplay,
        Anim = YAHOO.util.Anim,
        anim,
        isPause = false,
        SP = this,
        autoInterval,
        delayInterval,
        isAnimated = true,
        direction = {
            E: 0,
            N: 1
        },
        marginTo = {
            E: "marginLeft",
            N: "marginTop"
        },
        region;
        var initSlide = function() {
            region = [el.offsetWidth, el.offsetHeight];
            if (SP.config.direction == "E" && SP.config.effect == "scroll") {
                $D.setStyle(slide, "width", region[0] * len + "px");
                $D.setStyle(slides, "float", "left")
            }
            $E.on(slides, "mouseover",
            function() {
                isPause = true
            });
            $E.on(slides, "mouseout",
            function() {
                isPause = false
            })
        };
        var initTriggle = function() {
            var oTriggle = doc.createElement("ul");
            oTriggle.className = "triggle";
            for (var i = 0; i < len; i++) {
                var oLi = doc.createElement("li"),
				triggle = doc.createElement("a"),
                slideLink = slides[i].getElementsByTagName("a")[0];
                switch (SP.config.mode) {
                case "title":
                    oLi.appendChild(doc.createTextNode(slideLink.title));
                    break;
                case "thumbnail":
                    var image = new Image(),
                    thumbnail = slideLink.getAttribute("ThumbNail");
                    if (thumbnail) {
                        image.src = thumbnail
                    } else {
                        image.src = "http://img.taoxie.com/blank.gif"
                    }
					triggle.appendChild(image);
                    oLi.appendChild(triggle);
                    break;
                case "none":
                default:
                    oLi.appendChild(doc.createTextNode(i + 1));
                    break
                }
                $E.on(oLi, "mouseover",
                function(ev, el) {
                    var next = el.idx;
                    delayInterval = setTimeout(function() {
                        SP.Play(next, true);
                    	isPause = true
                    },
                    (!isAnimated ? .5 : .1) * 1000)
                },
                {
                    idx: i
                });
                $E.on(oLi, "mouseout",
                function() {
                    isPause = false;
                    clearTimeout(delayInterval)
                });
                oTriggle.appendChild(oLi);
                triggles.push(oLi)
            }
            el.appendChild(oTriggle)
        };
        var Toggle = function(n) {
            if (current) {
                $D.removeClass(current, "current")
            }
            $D.addClass(triggles[n], "current");
            current = triggles[n]
        };
        var init = function() {
            initSlide();
            if (SP.config.hasTriggle) {
                initTriggle();
                Toggle(index)
            }
            if (autoplay) {
                SP.AutoPlay()
            }
        };
        this.Pause = function() {
            clearInterval(autoInterval);
            isPause = true
        };
        var Normal = function(next) {
            isAnimated = false;
            $D.setStyle(slides[index], "display", "none");
            $D.setStyle(slides[next], "display", "block");
            isAnimated = true
        };
        var Scroll = function(next) {
            var to = 0;
            isAnimated = false;
            to = -next * region[direction[SP.config.direction]];
            if (!anim) {
                anim = new Anim(slide)
            }
            anim.attributes[marginTo[SP.config.direction]] = {
                to: to
            };
            anim.duration = SP.config.duration;
            anim.method = SP.config.method;
            anim.onComplete.subscribe(function() {
                isAnimated = true
            });
            anim.animate()
        };
        var Fade = function(next) {//播放完切换，改成即刻切换
            isAnimated = false;//是否已经动画完成
            var anim1, anim2;
            var FadeIn = function() {//渐隐
                var attributes = {
                    opacity: {
                        from: 1,
                        to: 0
                    }
                };
                anim1 = new Anim(slides[index], attributes, SP.config.duration, SP.config.method);
                anim1.onComplete.subscribe(FadeOut);
                anim1.animate()
            };
            var FadeOut = function() {//渐显
                $D.setStyle(slides[index], "display", "none");
                $D.setStyle(slides[next], "display", "block");
                $D.setStyle(slides[next], "opacity", 0);
                var attributes = {
                    opacity: {
                        from: .5,
                        to: 1
                    }
                };
                anim2 = new Anim(slides[next], attributes, SP.config.duration, SP.config.method);
                anim2.onComplete.subscribe(function() {
                    isAnimated = true
                });
                anim2.animate()
            };
			//如果都在运动，则全部停止
//			if(next!=index){
//            	if(anim1){
//					anim1.stop();
//				}
//				if(anim2){
//					anim2.stop();
//				}
//				$D.setStyle(slides[next], "display", "none");
//                $D.setStyle(slides[index], "display", "block");
//                $D.setStyle(slides[index], "opacity", 1);
//				isAnimated = false;
//			}
			FadeIn()
        };
        this.Play = function(next, flag) {
            if (next == index) return;
            if (flag && autoInterval) clearInterval(autoInterval);
            SP.SlideEffect(next);
            var t1 = setInterval(function() {
                if (isAnimated) {
                    index = next;
                    clearInterval(t1)
                }
            },
            100);
            if (this.config.hasTriggle) {
                Toggle(next)
            }
            if (flag && !isPause) SP.AutoPlay()
        };
        this.SlideEffect = function(next) {
            switch (this.config.effect) {
            case "scroll":
                Scroll(next);
                break;
            case "fade":
                Fade(next);
                break;
            case "none":
            default:
                Normal(next);
                break
            }
        };
        this.AutoPlay = function() {
            var callback = function() {
                if (isAnimated && !isPause) {
                    var next = (index + 1) % len;
                    SP.Play(next, false)
                }
            };
            autoInterval = setInterval(callback, this.config.delay)
        };
        init();
        this.version = "1.0"
    };
    Shoes.SlidePlayer = SlidePlayer
})();